mruby 4.0.0
mruby is the lightweight implementation of the Ruby language
Loading...
Searching...
No Matches
ops.h
1/* operand types:
2 + Z: no operand
3 + B: 8bit
4 + BB: 8+8bit
5 + BBB: 8+8+8bit
6 + BS: 8+16bit
7 + BSS: 8+16+16bit
8 + S: 16bit
9 + W: 24bit
10*/
11
12/*-----------------------------------------------------------------------
13operation code operands semantics
14------------------------------------------------------------------------*/
15OPCODE(NOP, Z) /* no operation */
16OPCODE(MOVE, BB) /* R[a] = R[b] */
17OPCODE(LOADL, BB) /* R[a] = Pool[b] */
18OPCODE(LOADI8, BB) /* R[a] = mrb_int(b) */
19OPCODE(LOADINEG, BB) /* R[a] = mrb_int(-b) */
20OPCODE(LOADI__1, B) /* R[a] = mrb_int(-1) */
21OPCODE(LOADI_0, B) /* R[a] = mrb_int(0) */
22OPCODE(LOADI_1, B) /* R[a] = mrb_int(1) */
23OPCODE(LOADI_2, B) /* R[a] = mrb_int(2) */
24OPCODE(LOADI_3, B) /* R[a] = mrb_int(3) */
25OPCODE(LOADI_4, B) /* R[a] = mrb_int(4) */
26OPCODE(LOADI_5, B) /* R[a] = mrb_int(5) */
27OPCODE(LOADI_6, B) /* R[a] = mrb_int(6) */
28OPCODE(LOADI_7, B) /* R[a] = mrb_int(7) */
29OPCODE(LOADI16, BS) /* R[a] = mrb_int(b) */
30OPCODE(LOADI32, BSS) /* R[a] = mrb_int((b<<16)+c) */
31OPCODE(LOADSYM, BB) /* R[a] = Syms[b] */
32OPCODE(LOADNIL, B) /* R[a] = nil */
33OPCODE(LOADSELF, B) /* R[a] = self */
34OPCODE(LOADTRUE, B) /* R[a] = true */
35OPCODE(LOADFALSE, B) /* R[a] = false */
36OPCODE(GETGV, BB) /* R[a] = getglobal(Syms[b]) */
37OPCODE(SETGV, BB) /* setglobal(Syms[b], R[a]) */
38OPCODE(GETSV, BB) /* R[a] = Special[Syms[b]] */
39OPCODE(SETSV, BB) /* Special[Syms[b]] = R[a] */
40OPCODE(GETIV, BB) /* R[a] = ivget(Syms[b]) */
41OPCODE(SETIV, BB) /* ivset(Syms[b],R[a]) */
42OPCODE(GETCV, BB) /* R[a] = cvget(Syms[b]) */
43OPCODE(SETCV, BB) /* cvset(Syms[b],R[a]) */
44OPCODE(GETCONST, BB) /* R[a] = constget(Syms[b]) */
45OPCODE(SETCONST, BB) /* constset(Syms[b],R[a]) */
46OPCODE(GETMCNST, BB) /* R[a] = R[a]::Syms[b] */
47OPCODE(SETMCNST, BB) /* R[a+1]::Syms[b] = R[a] */
48OPCODE(GETUPVAR, BBB) /* R[a] = uvget(b,c) */
49OPCODE(SETUPVAR, BBB) /* uvset(b,c,R[a]) */
50OPCODE(GETIDX, B) /* R[a] = R[a][R[a+1]] */
51OPCODE(GETIDX0, BB) /* R[a] = R[b][0]; a+1 for method call */
52OPCODE(SETIDX, B) /* R[a][R[a+1]] = R[a+2] */
53OPCODE(JMP, S) /* pc+=a */
54OPCODE(JMPIF, BS) /* if R[a] pc+=b */
55OPCODE(JMPNOT, BS) /* if !R[a] pc+=b */
56OPCODE(JMPNIL, BS) /* if R[a]==nil pc+=b */
57OPCODE(JMPUW, S) /* unwind_and_jump_to(a) */
58OPCODE(EXCEPT, B) /* R[a] = exc */
59OPCODE(RESCUE, BB) /* R[b] = R[a].isa?(R[b]) */
60OPCODE(RAISEIF, B) /* raise(R[a]) if R[a] */
61OPCODE(MATCHERR, B) /* raise NoMatchingPatternError unless R[a] */
62OPCODE(SSEND, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
63OPCODE(SSEND0, BB) /* R[a] = self.send(Syms[b]) (no args) */
64OPCODE(SSENDB, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
65OPCODE(SEND, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
66OPCODE(SEND0, BB) /* R[a] = R[a].send(Syms[b]) (no args) */
67OPCODE(SENDB, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
68OPCODE(CALL, Z) /* self.call(*, **, &) (But overlay the current call frame; tailcall) */
69OPCODE(BLKCALL, BB) /* R[a] = R[a].call(R[a+1],... ,R[a+b]); direct block call */
70OPCODE(SUPER, BB) /* R[a] = super(R[a+1],... ,R[a+b+1]) */
71OPCODE(ARGARY, BS) /* R[a] = argument array (16=m5:r1:m5:d1:lv4) */
72OPCODE(ENTER, W) /* arg setup according to flags (24=n1:m5:o5:r1:m5:k5:d1:b1) */
73OPCODE(KEY_P, BB) /* R[a] = kdict.key?(Syms[b]) */
74OPCODE(KEYEND, Z) /* raise unless kdict.empty? */
75OPCODE(KARG, BB) /* R[a] = kdict[Syms[b]]; kdict.delete(Syms[b]) */
76OPCODE(RETURN, B) /* return R[a] (normal) */
77OPCODE(RETURN_BLK, B) /* return R[a] (in-block return) */
78OPCODE(RETSELF, Z) /* return self */
79OPCODE(RETNIL, Z) /* return nil */
80OPCODE(RETTRUE, Z) /* return true */
81OPCODE(RETFALSE, Z) /* return false */
82OPCODE(BREAK, B) /* break R[a] */
83OPCODE(BLKPUSH, BS) /* R[a] = block (16=m5:r1:m5:d1:lv4) */
84OPCODE(ADD, B) /* R[a] = R[a]+R[a+1] */
85OPCODE(ADDI, BB) /* R[a] = R[a]+mrb_int(b) */
86OPCODE(SUB, B) /* R[a] = R[a]-R[a+1] */
87OPCODE(SUBI, BB) /* R[a] = R[a]-mrb_int(b) */
88OPCODE(ADDILV, BBB) /* R[a] = R[a]+mrb_int(c); R[b],R[b+1] for method call */
89OPCODE(SUBILV, BBB) /* R[a] = R[a]-mrb_int(c); R[b],R[b+1] for method call */
90OPCODE(MUL, B) /* R[a] = R[a]*R[a+1] */
91OPCODE(DIV, B) /* R[a] = R[a]/R[a+1] */
92OPCODE(EQ, B) /* R[a] = R[a]==R[a+1] */
93OPCODE(LT, B) /* R[a] = R[a]<R[a+1] */
94OPCODE(LE, B) /* R[a] = R[a]<=R[a+1] */
95OPCODE(GT, B) /* R[a] = R[a]>R[a+1] */
96OPCODE(GE, B) /* R[a] = R[a]>=R[a+1] */
97OPCODE(ARRAY, BB) /* R[a] = ary_new(R[a],R[a+1]..R[a+b]) */
98OPCODE(ARRAY2, BBB) /* R[a] = ary_new(R[b],R[b+1]..R[b+c]) */
99OPCODE(ARYCAT, B) /* ary_cat(R[a],R[a+1]) */
100OPCODE(ARYPUSH, BB) /* ary_push(R[a],R[a+1]..R[a+b]) */
101OPCODE(ARYSPLAT, B) /* R[a] = ary_splat(R[a]) */
102OPCODE(AREF, BBB) /* R[a] = R[b][c] */
103OPCODE(ASET, BBB) /* R[b][c] = R[a] */
104OPCODE(APOST, BBB) /* *R[a],R[a+1]..R[a+c] = R[a][b..] */
105OPCODE(INTERN, B) /* R[a] = intern(R[a]) */
106OPCODE(SYMBOL, BB) /* R[a] = intern(Pool[b]) */
107OPCODE(STRING, BB) /* R[a] = str_dup(Pool[b]) */
108OPCODE(STRCAT, B) /* str_cat(R[a],R[a+1]) */
109OPCODE(HASH, BB) /* R[a] = hash_new(R[a],R[a+1]..R[a+b*2-1]) */
110OPCODE(HASHADD, BB) /* hash_push(R[a],R[a+1]..R[a+b*2]) */
111OPCODE(HASHCAT, B) /* R[a] = hash_cat(R[a],R[a+1]) */
112OPCODE(LAMBDA, BB) /* R[a] = lambda(Irep[b],L_LAMBDA) */
113OPCODE(BLOCK, BB) /* R[a] = lambda(Irep[b],L_BLOCK) */
114OPCODE(METHOD, BB) /* R[a] = lambda(Irep[b],L_METHOD) */
115OPCODE(RANGE_INC, B) /* R[a] = range_new(R[a],R[a+1],FALSE) */
116OPCODE(RANGE_EXC, B) /* R[a] = range_new(R[a],R[a+1],TRUE) */
117OPCODE(OCLASS, B) /* R[a] = ::Object */
118OPCODE(CLASS, BB) /* R[a] = newclass(R[a],Syms[b],R[a+1]) */
119OPCODE(MODULE, BB) /* R[a] = newmodule(R[a],Syms[b]) */
120OPCODE(EXEC, BB) /* R[a] = blockexec(R[a],Irep[b]) */
121OPCODE(DEF, BB) /* R[a].newmethod(Syms[b],R[a+1]); R[a] = Syms[b] */
122OPCODE(TDEF, BBB) /* target_class.newmethod(Syms[b],Irep[c]); R[a] = Syms[b] */
123OPCODE(SDEF, BBB) /* R[a].singleton_class.newmethod(Syms[b],Irep[c]); R[a] = Syms[b] */
124OPCODE(ALIAS, BB) /* alias_method(target_class,Syms[a],Syms[b]) */
125OPCODE(UNDEF, B) /* undef_method(target_class,Syms[a]) */
126OPCODE(SCLASS, B) /* R[a] = R[a].singleton_class */
127OPCODE(TCLASS, B) /* R[a] = target_class */
128OPCODE(DEBUG, BBB) /* print a,b,c */
129OPCODE(ERR, B) /* raise(LocalJumpError, Pool[a]) */
130OPCODE(EXT1, Z) /* make 1st operand (a) 16bit */
131OPCODE(EXT2, Z) /* make 2nd operand (b) 16bit */
132OPCODE(EXT3, Z) /* make 1st and 2nd operands 16bit */
133OPCODE(STOP, Z) /* stop VM */